﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace SimpleGameFramework.Localization
{
    /// <summary>
    /// 本地化辅助器基类
    /// </summary>
    public abstract class LocalizationHelperBase
    {
        /// <summary>
        /// 获取系统语言
        /// </summary>
        public abstract Language SystemLanguage { get; }


        /// <summary>
        /// 加载字典
        /// </summary>
        /// <param name="dictionaryAsset">字典资源</param>
        /// <param name="userData">用户自定义数据</param>
        /// <returns>加载是否成功</returns>
        public bool LoadDictionary(object dictionaryAsset, object userData)
        {
            LoadDictionaryInfo loadDictionaryInfo = (LoadDictionaryInfo)userData;
            return LoadDictionary(loadDictionaryInfo.DictionaryName, dictionaryAsset, loadDictionaryInfo.UserData);
        }

        /// <summary>
        /// 解析字典
        /// </summary>
        /// <param name="text">要解析的字典文本</param>
        /// <param name="userData">用户自定义数据</param>
        /// <returns>是否解析字典成功</returns>
        public abstract bool ParseDictionary(string text, object userData);

        /// <summary>
        /// 释放字典资源
        /// </summary>
        /// <param name="dictionaryAsset">要释放的字典资源</param>
        public abstract void ReleaseDictionaryAsset(object dictionaryAsset);

        /// <summary>
        /// 加载字典
        /// </summary>
        /// <param name="dictionaryName">字典名称</param>
        /// <param name="dictionaryAsset">字典资源</param>
        /// <param name="userData">用户自定义数据</param>
        /// <returns>加载是否成功</returns>
        protected abstract bool LoadDictionary(string dictionaryName, object dictionaryAsset, object userData);
    }
}

